package 力扣._7020_统计对称整数的数目;

public class Solution {
    public int countSymmetricIntegers(int low, int high) {
        int total = 0;
        for (int i = low; i <= high; i++) {
            int len = 0;
            int num = i;
            while (num > 0) {
                len++;
                num /= 10;
            }
            if (len % 2 == 0) {
                num = i;
                int sum1 = 0, sum2 = 0;
                for (int j = 0; j < len / 2; j++) {
                    sum1 += num % 10;
                    num /= 10;
                }
                for (int j = len / 2; j < len; j++) {
                    sum2 += num % 10;
                    num /= 10;
                }
                if (sum1 == sum2)
                    total++;
            }
        }
        return total;
    }
}
